package controller;

import model.entity.MapAbilityList;
import model.entity.Entity;

public class ControlAbilityMediator {
    private Entity e;
    private MapAbilityList abilities;

    public ControlAbilityMediator(Entity e) {
        this.e = e;
        abilities = new MapAbilityList(e);

        KeyController.addUseDefaultAttack(new UseDefaultAttack(this));
        KeyController.addUseUtilityAbility(new UseUtilityAbility(this));
        KeyController.addNextUtilityAbility(new NextUtilityAbility(this));
        KeyController.addPrevUtilityAbility(new PrevUtilityAbility(this));
    }
    
    public void useDefaultAttack() {
        e.useDefaultAttack();
    }
    
    public void useUtilityAbility() {
        abilities.activate();
    }
    
    public void nextUtilityAbility() {
        abilities.next();
    }
    
    public void prevUtilityAbility() {
        abilities.prev();
    }

    private class UseDefaultAttack implements Command {
        ControlAbilityMediator m;

        public UseDefaultAttack(ControlAbilityMediator m) {
            this.m = m;
        }

        public void execute() {
            m.useDefaultAttack();
        }
    }

    private class UseUtilityAbility implements Command {
        ControlAbilityMediator m;

        public UseUtilityAbility(ControlAbilityMediator m) {
            this.m = m;
        }

        public void execute() {
            m.useUtilityAbility();
        }
    }

    private class NextUtilityAbility implements Command {
        ControlAbilityMediator m;
        
        public NextUtilityAbility(ControlAbilityMediator m) {
            this.m = m;
        }

        public void execute() {
            m.nextUtilityAbility();
        }
    }

    private class PrevUtilityAbility implements Command {
        ControlAbilityMediator m;

        public PrevUtilityAbility(ControlAbilityMediator m) {
            this.m = m;
        }

        public void execute() {
            m.prevUtilityAbility();
        }
    }
}